package su.NewFeatureType;

import su.Ner.NerDataSequence;
import iitb.CRF.DataSequence;
import iitb.Model.FeatureGenImpl;
import iitb.Model.WordsInTrain;

@SuppressWarnings("serial")
public class NextWordFeatures extends StateFeatures {

	WordsInTrain dict;
	String word;
	static int RARE_THRESHOLD=0;
	
	public NextWordFeatures(FeatureGenImpl fgen, WordsInTrain _dict,int baseId) {
		super(fgen, baseId, NerDataSequence.labelNum * _dict.dictionaryLength());
		dict=_dict;
	}
	
	public boolean startScanFeaturesAt(DataSequence data, int prevPos, int pos) {
		if(pos==data.length()-1) return false;
		word=((String)(String)data.x(pos+1)).toLowerCase();
		if (dict.count(word) <= RARE_THRESHOLD) return false;
		setParams("NW."+word, dict.getIndex(word));
		stateId=0;
		return true;
	}
}
